#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

void duplicateZeros(int* arr, int arrSize) {
    int cur = 0, dest = -1;
    while (dest < arrSize - 1)
    {
        if (arr[cur] != 0)
        {
            dest++;
        }
        else {
            dest += 2;
        }
        if(dest< arrSize - 1)
        cur++;
    }
    while (cur >= 0) {
        if (arr[cur] != 0) {
            arr[dest] = arr[cur];
        }
        else {
            arr[dest] = arr[cur];
            arr[--dest] = arr[cur];
        }
        dest--;
        cur--;
    }
}

int main()
{
    int arr[] = { 1,0,2,3,0,4,5,0 };
    int sz = sizeof(arr) / sizeof(arr[0]);
    duplicateZeros(arr, sz);
    for (int i = 0; i < sz; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}